<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">Getway跳板机管理</h1>
                    <small class="text-muted">Getway配置文件</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="全局配置文件管理">
                    <div class="panel panel-default" ng-controller="getwayHostConfigCtrl">
                        <div class="panel-body">
                            <div>
                                <form class="form-inline" role="form">
                                    <div class="form-group">
                                        <button ng-show="pbulicFileList == null || pbulicFileList.length ==0"
                                                type="button" class="btn btn-success" ng-click="addItem()"><span
                                                class="glyphicon glyphicon-plus"></span>新增全局配置文件
                                        </button>

                                        <button
                                                type="button" class="btn btn-danger" ng-click="doSetup()"><span
                                                class="icon icon-wrenc"></span>初始化Getway
                                        </button>

                                        <button
                                                type="button" class="btn btn-success" ng-click="doQuery()"><span
                                                class="glyphicon glyphicon-repeat"></span>刷新
                                        </button>
                                    </div>
                                </form>
                            </div>

                            <div style="margin-top: 5px;">
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <td>文件组名</td>
                                        <td class="col-md-6">配置文件（请在GETWAY_HOST_CONF_FILE中配置）</td>
                                        <td>使用类型</td>
                                        <td>操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="item in pbulicFileList">
                                        <td>{{item.fileGroupDO.groupName}}</td>
                                        <td>
                                            <b style="color: #777">{{item.filePath}}</b>
                                            </br>
                                            <b style="color: #286090">{{item.fileName}}</b>
                                            <b class="pull-right">{{item.fileDesc}}</b>
                                        </td>
                                        <td>
                                            <b style="color: #f4ca06"
                                               ng-if="item.useType == 0 || item.useTypeDO == null">all</b>
                                            <b ng-if="item.useType == 10">{{item.useTypeDO.typeName}}</b>
                                            <b ng-if="item.useType == 1">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: #990000" ng-if="item.useType == 2">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: #ec971f" ng-if="item.useType == 3">{{item.useTypeDO.typeName}}</b>
                                            <b ng-if="item.useType == 4">{{item.useType.typeName}}</b>
                                            <b ng-if="item.useType == 5">{{item.useType.typeName}}</b>
                                            <b style="color: #286090" ng-if="item.useType == 6">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: #d9534f" ng-if="item.useType == 7">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: #449d44" ng-if="item.useType == 8">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: #5bc0de" ng-if="item.useType == 9">{{item.useTypeDO.typeName}}</b>
                                            <b style="color: black"
                                               ng-if="item.useType > 9">{{item.useTypeDO.typeName}}</b>
                                        </td>
                                        <td>
                                            <button ng-click="editItem(item)"
                                                    class="btn btn-xs"
                                                    ng-disabled="butEditDisabled"
                                                    style="margin-left: 5px; background-color: #2e6da4; color: white;">
                                                <i class="glyphicon glyphicon-edit"></i>编辑
                                            </button>

                                            <button ng-click="launchItem(item.id)"
                                                    class="btn btn-xs"
                                                    style="margin-left: 5px; background-color: limegreen; color: white;">
                                                <span class="glyphicon glyphicon-search"></span>预览
                                            </button>

                                            <button ng-click="createItem(item.id)"
                                                    class="btn btn-xs"
                                                    ng-disabled="butSaveDisabled"
                                                    style="margin-left: 5px; background-color: #ff8700; color: white;">
                                                <i class="fa fa-spin fa-spinner" ng-show="butSaveSpinDisabled"></i>
                                                <i class="glyphicon glyphicon-save" ng-show="!butSaveSpinDisabled"></i>保存
                                            </button>

                                            <button ng-click="invokeItem(item.id)" ng-show="false"
                                                    class="btn btn-xs"
                                                    ng-disabled="butInvokeDisabled"
                                                    uib-popover-html="'同步配置并生效'" popover-trigger="'mouseenter'"
                                                    style="margin-left: 5px; background-color: #ff5f87; color: white;">
                                                <i class="fa fa-spin fa-spinner" ng-show="butInvokeSpinDisabled"></i>
                                                <i class="icon icon-control-play" ng-show="!butInvokeSpinDisabled"></i>执行
                                            </button>

                                            <button ng-click="delItem(item.id)"
                                                    class="btn btn-xs pull-right"
                                                    ng-disabled="butDelDisabled"
                                                    style="background-color: red; color: white;">
                                                <i class="glyphicon glyphicon-remove"></i>删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </uib-tab>

                <uib-tab index="1" heading="用户配置文件管理">
                    <div ng-controller="getwayUserConfigCtrl">
                        <div style="margin-top: 5px;" class="panel panel-default">
                            <div class="panel-body">
                                <form class="form-inline" role="form">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon">授权用户</span>
                                            <input type="text" class="form-control" ng-model="username"
                                                   placeholder="授权用户">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <button type="button" class="btn btn-info" ng-click="doQuery()"><span
                                                class="glyphicon glyphicon-search"></span>搜索
                                        </button>
                                    </div>

                                    <!--<div class="form-group">-->
                                        <!--<button type="button" class="btn btn-success" ng-click="addUser()">-->
                                            <!--<span class="glyphicon glyphicon-plus"></span>新建用户-->
                                        <!--</button>-->
                                    <!--</div>-->

                                    <div class="form-group">
                                        <button type="button" class="btn btn-info"
                                                ng-click="createAllUserGroupConfigFile()"><span
                                                class="icon icon-users"></span>重新生成用户配置
                                        </button>
                                    </div>
                                </form>
                                <div style="margin-top: 5px;">
                                    <table class="table table-hover table-bordered table-striped">
                                        <thead>
                                        <tr>
                                            <td>用户</td>
                                            <td>姓名Email</td>
                                            <td>授权服务器组</td>
                                            <td>更新时间</td>
                                            <td>操作</td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="item in pageData">
                                            <td>{{item.username}}</td>
                                            <td>{{item.displayName}}
                                               <span ng-shwo="item.mail != ''"><{{item.mail}}></span>
                                            </td>
                                            <td>
                                                <span class="badge pull-right" ng-if="item.servers == 0">{{item.servers}}</span>
                                                <span class="badge pull-right bg-success"
                                                      ng-if="item.servers > 0 && item.servers < 10">{{item.servers}}</span>
                                                <span class="badge pull-right bg-info" ng-if="item.servers >= 10">{{item.servers}}</span>
                                            </td>
                                            <td>{{(item.gmtModify == null || item.gmtModify == '') ? item.gmtCreate :
                                                item.gmtModify}}
                                            </td>
                                            <td>
                                                <button ng-click="launchItem(item)" ng-show="item.servers > 0"
                                                        class="btn btn-xs"
                                                        style="margin-left: 5px; background-color: limegreen; color: white;">
                                                    <span class="glyphicon glyphicon-search"></span>预览
                                                </button>

                                                <!--<button ng-click="createItem(item)"-->
                                                        <!--class="btn btn-xs"-->
                                                        <!--ng-disabled="butSaveDisabled"-->
                                                        <!--style="margin-left: 5px; background-color: #ff8700; color: white;">-->
                                                    <!--<i class="fa fa-spin fa-spinner" ng-show="butSaveSpinDisabled"></i>-->
                                                    <!--<i class="glyphicon glyphicon-save" ng-show="!butSaveSpinDisabled"></i>保存-->
                                                <!--</button>-->
                                            </td>
                                        </tr>
                                        </tbody>
                                        <tfoot>
                                        <tr>
                                            <td colspan="10">
                                                <ul style="margin: 0px; float: right;" uib-pagination
                                                    total-items="totalItems" ng-model="currentPage"
                                                    items-per-page="pageLength" max-size="10" ng-change="pageChanged()"
                                                    previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                            </td>
                                        </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </uib-tab>

                <uib-tab index="2" heading="Getway参数配置">
                    <div class="panel panel-default" ng-controller="getwayConfigCtrl">
                        <div class="panel-body">
                            <form class="form-horizontal">
                                <!--<div class="form-group col-lg-12">-->
                                    <!--<label class="col-lg-3 control-label"><span style="color: #ec2121;">*</span>GETWAY_KEYSTORE_FILE_PATH</label>-->
                                    <!--<div class="col-lg-6">-->
                                        <!--<input type="text" class="form-control" placeholder="Aliyun ECS AccessKey"-->
                                               <!--uib-popover-html="'全局管理密钥路径'"-->
                                               <!--popover-trigger="'mouseenter'"-->
                                               <!--ng-model="configMap.GETWAY_KEYSTORE_FILE_PATH.value">-->
                                    <!--</div>-->
                                <!--</div>-->

                                <div class="form-group col-lg-12">
                                    <label class="col-lg-3 control-label"><span style="color: #ec2121;">*</span>GETWAY_KEY_FILE</label>
                                    <div class="col-lg-6">
                                        <input type="text" class="form-control" placeholder="用户密钥文件名称，此参数不要修改"
                                               uib-popover-html="'用户密钥文件名称，此参数不要修改'"
                                               popover-trigger="'mouseenter'"
                                               ng-model="configMap.GETWAY_KEY_FILE.value">
                                    </div>
                                </div>

                                <div class="form-group col-lg-12">
                                    <label class="col-lg-3 control-label"><span style="color: #ec2121;">*</span>GETWAY_KEY_PATH</label>
                                    <div class="col-lg-6">
                                        <input type="text" class="form-control"
                                               placeholder="查询的地域ID:华东1,香港,美国西部1,按此格式添加:cn-hangzhou,cn-hongkong,us-west-1"
                                               uib-popover-html="'查询的区域ID,可在查询并测试配置中查看区域名称对应的地域ID'"
                                               popover-trigger="'mouseenter'"
                                               ng-model="configMap.GETWAY_KEY_PATH.value">
                                    </div>
                                </div>

                                <div class="form-group col-lg-12">
                                    <label class="col-lg-3 control-label"><span style="color: #ec2121;">*</span>GETWAY_USER_CONF_PATH</label>
                                    <div class="col-lg-6">
                                        <input type="text" class="form-control"
                                               placeholder="查询的地域ID:华东1,香港,美国西部1,按此格式添加:cn-hangzhou,cn-hongkong,us-west-1"
                                               uib-popover-html="'查询的区域ID,可在查询并测试配置中查看区域名称对应的地域ID'"
                                               popover-trigger="'mouseenter'"
                                               ng-model="configMap.GETWAY_USER_CONF_PATH.value">
                                    </div>
                                </div>


                                <div class="form-group col-lg-12">
                                    <label class="col-lg-3 control-label"><span style="color: #ec2121;">*</span>GETWAY_HOST_CONF_FILE</label>
                                    <div class="col-lg-6">
                                        <input type="text" class="form-control"
                                               placeholder="查询的地域ID:华东1,香港,美国西部1,按此格式添加:cn-hangzhou,cn-hongkong,us-west-1"
                                               uib-popover-html="'查询的区域ID,可在查询并测试配置中查看区域名称对应的地域ID'"
                                               popover-trigger="'mouseenter'"
                                               ng-model="configMap.GETWAY_HOST_CONF_FILE.value">
                                    </div>
                                </div>
                                <!--按钮-->
                                <div class="form-group">

                                    <div style="text-align:center;">

                                        <button class="btn btn-xs"
                                                style="background-color:  #2e6da4; color: white;"
                                                ng-click="updateConfig()">保存配置
                                        </button>

                                    </div>
                                </div>

                            </form>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="configFile">
    <div ng-include="'tpl/modal/configFile/getway_config_file_modal.html'"></div>
</script>

<!--自动同步配置文件到主机info-->
<script type="text/ng-template" id="configCopyInfo">
    <div ng-include="'tpl/modal/configFile/getway_config_copy_info_modal.html'"></div>
</script>

<script type="text/ng-template" id="configFileInfo">
    <div ng-include="'tpl/modal/configFile/config_file_info_modal.html'"></div>
</script>


<!--首次使用初始化Getway服务器-->
<script type="text/ng-template" id="setupGetwayModal">
    <div ng-include="'tpl/modal/configFile/setup_getway_modal.html'"></div>
</script>